home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / disp182a.zip / DRVSRC / VESA_S3.ASM < prev    next >
Assembly Source File  |  1993-12-06  |  15KB  |  505 lines

  1. ;--------------------------------------------------------------------------
  2. ; This is file VESA_S3.ASM
  3. ;
  4. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  5. ; Copyright (C) 1992 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221
  6. ; Copyright (C) 1992 Shayne Hughes, UC Davis, CA 95616
  7. ;
  8. ; This file is distributed under the terms listed in the document
  9. ; "copying.dj", available from DJ Delorie at the address above.
  10. ; A copy of "copying.dj" should accompany this file; if not, a copy
  11. ; should be available from where this file was obtained.  This file
  12. ; may not be distributed without a verbatim copy of "copying.dj".
  13. ;
  14. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  15. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. ;--------------------------------------------------------------------------
  17.  
  18. ; NOTE: this file was formerly called STEALTH.ASM
  19. ; It seems that for once the industry is succeeding in manufacturing
  20. ; compatible graphics boards, as this driver, orginally written for a
  21. ; Diamond Stealth board seems to work unchanged on Orchid F1280 and
  22. ; similar S3 based boards, AND EVEN local bus S3 boards.
  23. ; Thanks to Shayne Hughes, we now have a paging routine for this
  24. ; driver. This allows direct memory access to the video RAM - although
  25. ; GRX is not using it.
  26.  
  27. _TEXT    segment byte public 'CODE'
  28. _TEXT    ends
  29. DGROUP  group    _TEXT,_DATA,_BSS
  30.     assume  cs:_TEXT,ds:DGROUP
  31. _DATA    segment word public 'DATA'
  32. d@    label    byte
  33. d@w    label    word
  34. _DATA    ends
  35. _BSS    segment word public 'BSS'
  36. b@    label    byte
  37. b@w    label    word
  38. _BSS    ends
  39. _TEXT    segment byte public 'CODE'
  40.     assume  cs:_TEXT,ds:DGROUP
  41.  
  42. include grdriver.inc
  43.  
  44. ;--------------------------------------------------------------------------
  45. ; DRIVER HEADER
  46. ;  The following entries MUST match the structure and constant
  47. ;  declarations in the file 'grdriver.h' of the GRX graphics library
  48. ;  The mode word should contain the following bitfields:
  49. ;     - the GRD_NEW_DRIVER bit set for any new format driver
  50. ;     - the adapter type field should be specified
  51. ;     - the memory size field should be specified
  52. ;     - the paging mode field should be specified
  53. ;  The mode set routine will OR in the plane bitfield as it will
  54. ;  change when different color number modes are requested.
  55. ;--------------------------------------------------------------------------
  56.  
  57.     dw    offset mode_set_routine
  58.     dw    offset paging_routine
  59. mode_W  dw    GRD_NEW_DRIVER+GRD_VGA+GRD_1024K+GRD_NO_RW
  60. ;
  61. ; The 'def_xx' fields are filled in by go32 from the corresponding
  62. ; fields of the 'GO32' environment variable
  63. ;
  64. def_tw  dw    80        ; text width
  65. def_th  dw    25        ; text height
  66. def_gw  dw    320        ; graphics width
  67. def_gh  dw    200        ; graphics height
  68. def_nc  dw    16        ; graphics colors
  69.     dw    offset driver_init_routine
  70.     dw    offset text_mode_table
  71.     dw    offset graphics_mode_table
  72.  
  73. ;
  74. ; Biggest text and graphics sizes
  75. ;
  76. Max_TW  equ    80
  77. Max_TH  equ    50
  78. Max_GWn equ    640        ; non interlaced!!!
  79. Max_GHn equ    480
  80. Max_GW  equ    640        ; may be interlaced
  81. Max_GH  equ    480
  82.  
  83.  
  84. ;--------------------------------------------------------------------------
  85. ; TABLE OF SUPPORTED TEXT MODES
  86. ;    - keep sorted by size
  87. ;    - end with an all 0 entry
  88. ;    - BIOS field = 0xff disables it
  89. ;    - fields:
  90. ;        width,  height, colors, BIOS#+  setup_procedure_index*256
  91. ;--------------------------------------------------------------------------
  92. text_mode_table        label word
  93.     dw    80,    25,    2,    007h +  00000h
  94.     dw    40,    25,    16,    001h +  00000h
  95.     dw    80,    25,    16,    003h +  00000h
  96.     dw    80,    28,    16,    003h +  00400h  ; 80x25 + reload 14 row font
  97.     dw    80,    50,    16,    003h +  00600h  ; 80x25 + reload 8 row font
  98.     dw    132,    25,    16,    109h +  00000h  ; VESA 109h mode
  99.     dw    132,    28,    16,    109h +  00400h  ; VESA 109h mode (132x25) + reload 14 row font
  100.     dw    132,    44,    16,    10ah +  00000h  ; VESA 10ah mode
  101.     dw    132,    50,    16,    109h +  00600h  ; VESA 109h mode (132x25) + reload 8 row font
  102.     dw    0,    0,    0,    000h +  00000h
  103.  
  104. ;--------------------------------------------------------------------------
  105. ; TABLE OF SUPPORTED GRAPHICS MODES
  106. ;    - keep sorted first by colors then by size
  107. ;    - end with an all 0 entry
  108. ;    - BIOS field = 0xff disables it
  109. ;    - fields:
  110. ;        width,  height, colors, BIOS#+  setup_procedure_index*256
  111. ;--------------------------------------------------------------------------
  112. graphics_mode_table    label word
  113.     dw    320,    200,    16,    00dh +  00000h
  114.     dw    640,    200,    16,    00eh +  00000h
  115.     dw    640,    350,    16,    010h +  00000h
  116.     dw    640,    480,    16,    012h +  00000h
  117.     dw    800,    600,    16,    002h +  00100h  ; VESA 102h mode
  118.     dw    320,    200,    256,    013h +  00000h
  119.     dw    640,    480,    256,    001h +  00200h  ; VESA S3 201h mode
  120.     dw    800,    600,    256,    003h +  00200h  ; VESA S3 203h mode
  121.     dw     1024,    768,    256,    005h +  00200h  ; VESA S3 205h mode
  122.     dw    0,    0,    0,    000h +  00000h
  123.  
  124. ;--------------------------------------------------------------------------
  125. ; TABLE OF SPECIAL SETUP PROCEDURES
  126. ;  You may need such procedures for:
  127. ;     -- reloading fonts on standard EGA or VGA for
  128. ;     higher resolution text modes
  129. ;     -- enable HiColor mode of some Super VGAs
  130. ;     -- Handle the parameter passing conventions of the VESA BIOS
  131. ;     -- put VGA into 256 color plane mode ("MODE X")
  132. ;     -- etc...
  133. ;  There should be one entry in the table for every non-zero
  134. ;  'setup_procedure_index' in the text and graphics mode tables.
  135. ;  The first entry in the table belongs to index 100h, and so on.
  136. ;  The special setup procedure is invoked via a near call.
  137. ;
  138. ;  Entry: DI=address of the mode record from the text or graphics
  139. ;      table to set up.
  140. ;
  141. ;  Exit:  Adapter configured
  142. ;      BX=driver mode word as it should be returned by the mode set
  143. ;         routine. Typically it involves picking up the mode word
  144. ;         from the header and OR-ing in the appropriate bitplane mode
  145. ;         bitfield. (This is not needed for text modes)
  146. ;      AX, CX, DX, SI can be trashed, PRESERVE DI!!!!
  147. ;
  148. ;  NOTE: This runs in real mode, but don't mess with the segment registers.
  149. ;--------------------------------------------------------------------------
  150. special_setup_table    label word
  151.     dw    offset  VESA_SVGA_mode_set    ; for 01xxh modes
  152.     dw    offset  VESA_S3_mode_set    ; for 02xxh accelerated S3 modes
  153.     dw    0
  154.     dw    offset  VGA_28_row_mode_set    ; for 28 row text modes
  155.     dw    offset  VGA_28_row_mode_set    ; for 28 row VESA text modes
  156.     dw    offset  VGA_50_row_mode_set    ; for 50 row text modes
  157.     dw    offset  VGA_50_row_mode_set    ; for 50 row VESA text modes
  158.  
  159. ;
  160. ; Routine to set up VGA 50 row mode
  161. ; interface is described above
  162. ;
  163. VGA_50_row_mode_set    proc    near
  164.     mov    ax,WORD PTR [di+6]    ; get base mode number
  165.     and    ah,1            ; clear setup proc index
  166.     je    std_50_mode
  167.     mov    bx,ax
  168.     mov    ax,4f02h
  169.     int    10h
  170.     cmp    ax,004fh        ; VESA error ?
  171.     je    mode_50_done
  172.     mov    ax,3            ; VESA error -- set 80x25 mode
  173. std_50_mode:
  174.     int    10h
  175. mode_50_done:
  176.     xor    bx,bx
  177.     mov    ax,1112h        ; load 8x8 font
  178.     int    10h
  179.     ret
  180. VGA_50_row_mode_set    endp
  181.  
  182. ;
  183. ; Routine to set up VGA 28 row mode
  184. ; interface is described above
  185. ;
  186. VGA_28_row_mode_set     proc     near
  187.     mov    ax,WORD PTR [di+6]    ; get base mode number
  188.     and    ah,1            ; clear setup proc index
  189.     je    std_28_mode
  190.     mov    bx,ax
  191.     mov    ax,4f02h
  192.     int    10h
  193.     cmp    ax,004fh        ; VESA error ?
  194.     je    mode_28_done
  195.     mov    ax,3            ; VESA error -- set 80x25 mode
  196. std_28_mode:
  197.     int    10h
  198. mode_28_done:
  199.     xor    bx,bx
  200.     mov    ax,1111h        ; load 8x14 font
  201.     int    10h
  202.     ret
  203. VGA_28_row_mode_set     endp
  204.  
  205. ;
  206. ; Routine to set up VESA SVGA modes
  207. ; only used for 16 color text and graphics modes
  208. ; interface is described above
  209. ;
  210. VESA_SVGA_mode_set    proc    near
  211.     mov    ax,4f02h
  212.     mov    bx,WORD PTR [di+6]
  213.     int    10h
  214.     mov    bx,0ffffh        ; error code
  215.     cmp    ax,004fh
  216.     jne    VESA_SVGA_error
  217.     mov    bx,mode_W
  218.     or    bx,GRD_4_PLANES
  219. VESA_SVGA_error:
  220.     ret
  221. VESA_SVGA_mode_set    endp
  222.  
  223. ; Routine to set up VESA S3 modes
  224. ; only used for 256 color graphics modes
  225. ; interface is described above
  226. ;
  227. VESA_S3_mode_set    proc    near
  228.     mov    ax,4f02h
  229.     mov    bx,WORD PTR [di+6]
  230.     int    10h
  231.     mov    bx,0ffffh        ; error code
  232.     cmp    ax,004fh
  233.     jne    VESA_S3_error
  234.     mov    bx,mode_W
  235.     xor    bx,(GRD_VGA XOR GRD_S3)
  236.     or    bx,GRD_8_PLANES
  237. VESA_S3_error:
  238.     ret
  239. VESA_S3_mode_set    endp
  240.  
  241.  
  242. ;-----------------------------------------------------